package com.wujing.scalatrait

import scala.annotation.tailrec

object TraitDemo03 {
  def main(args: Array[String]): Unit = {
    val mysql = new Mysql6 with Db7
    println(mysql.operatype)

  }
}



trait Operate7{
  var operatype:String
  def insert()
}

trait Db7 extends Operate7{
  var operatype:String="insert"

  override def insert(): Unit = {}

}

class Mysql6{}
trait LogException extends Exception{
  def log ={
    getMessage
  }
}

//集成了LogException
//LogException 集成了 Exception
//所以 UnhappyExcetion 就成了Exception 的子类
class UnhappyException extends LogException{
  override def getMessage: String = "不开心"
}

//如果混入特质的类已经继承了另外一个类，则要求A类是特质超类的子类
//否则就出现了多继承的现象，发生错误

//成功样例
class UnhappyException2 extends IndexOutOfBoundsException with LogException{
  override def getMessage: String = "不开心"
}


//失败案例
//class CCC{}
//class UnhappyException3 extends CCC with LogException{
//  override def getMessage: String = "不开心"
//}